/**
 * Upper case first char
 * @param {String} string
 */
export default function asPercent(number, decimal = 2) {
  let priceNumber = number
  if (typeof priceNumber === 'string') {
    priceNumber = priceNumber.replace(/[^\d.]/gi, '')
  }
  var price = parseFloat(priceNumber) * 100
  if (decimal) {
    price = price.toFixed(decimal)
  }
  return price.toString().replace(/^-?\d+/g, m => m.replace(/(?=(?!\b)(\d{3})+$)/g, ',')) + '%'
}
